#include "config.h"
#include "front.h"
#include "ap_res.h"

u8 language_judge(void)
{
	u32 xdata LanguageFlag;
	SDFILE xdata lang_fp;
	u8 xdata langfile[]="L_Conf.res";
	u8 i;

	if(!ResOpen(langfile,&lang_fp))
	{
		return 0;
	}
	VMRead((u8 xdata *)&LanguageMode,LANGUAGE_MODE,1,COMVAL_VM);
	spiFlashRead((u8 xdata *)&LanguageFlag,lang_fp.addr + 1,4);


	if( !( LanguageFlag & BIT(LanguageMode-1) ) )
	{
		for(i=0;i<LANGUAGEID_SUM;i++)
		{
			if(LanguageFlag & BIT(i))
			{
				LanguageMode = i + 1;
				if(LanguageMode >= Chinese_Simplified && LanguageMode <= Arabic)
					return 1;
			}
		}
		return 0;			
	}
	else
		return 1;
}